home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha II 1.21 / source / Code ƒ / H-Initialize.p < prev    next >
Encoding:
Text File  |  1993-07-01  |  18.6 KB  |  311 lines  |  [TEXT/PJMM]

  1. unit Initialize;
  2.  
  3. interface
  4.     uses
  5.         Sound, Palettes, Globals, AboutWndo, Dialogs, GameUtils, Enemies, GlyphaGuts;
  6.  
  7.     procedure InitVariables;
  8.  
  9. implementation
  10.  
  11. {=================================}
  12.  
  13.     procedure InitVariables;
  14.         var
  15.             sizeOfOff, offRowBytes, dummyLong: LongInt;
  16.             i, i2, theDepth, howManySounds, vertOrigin: Integer;
  17.             rawPointer: Ptr;
  18.             tempByte: SignedByte;
  19.             thePict: PicHandle;
  20.             tempRect: Rect;
  21.             theSnd: Handle;
  22.             ignore: Boolean;
  23.  
  24. {------------------}
  25.  
  26.         procedure CheckOurEnvirons;
  27.             
  28.         rawPointer := NewPtr(SizeOf(GrafPort));    {Initialize and setup offscreen}
  29.         offMaskPort := GrafPtr(rawPointer);
  30.         OpenPort(offMaskPort);
  31.         offMaskBits := NewBitMap(offMaskMap, smallOffArea);
  32.         SetPortBits(offMaskMap);
  33.         EraseRect(offMaskMap.bounds);
  34.         SetPort(offMaskPort);
  35.         ClipRect(smallOffArea);
  36.         CopyRgn(offMaskPort^.clipRgn, offMaskPort^.visRgn);
  37.  
  38.         thePict := GetPicture(maskPictID);    {Get Picture into memory}
  39.         if (thePict <> nil) then            {Only use handle if it is valid}
  40.             begin
  41.                 HLock(Handle(thePict));            {Lock the handle before using it}
  42.                 tempRect := thePict^^.picFrame;
  43.                 DrawPicture(thePict, tempRect);
  44.                 ReleaseResource(Handle(thePict));
  45.                 HUnLock(Handle(thePict));        {Unlock the picture again}
  46.             end
  47.         else
  48.             begin
  49.                 GenericAlert(4);
  50.                 ExitToShell;
  51.             end;
  52.  
  53.         numberOfStones := 4;
  54.         levelStart := 1;
  55.         levelOn := 0;
  56.         mortalsStart := defaultNum;
  57.         mortals := mortalsStart;
  58.         score := 0;
  59.         GetDateTime(RandSeed);
  60.         playing := FALSE;
  61.         pausing := FALSE;
  62.  
  63.         chanPtr := nil;
  64.         soundPriority := noSound;
  65.  
  66.         SetRect(playerRects[0, 0], 260, 38, 308, 86);        {Rects for player facing right    }
  67.         SetRect(playerRects[0, 1], 309, 38, 357, 86);        {walking}
  68.         SetRect(playerRects[0, 2], 260, 38, 308, 86);        {walking}
  69.         SetRect(playerRects[0, 3], 309, 38, 357, 86);        {walking}
  70.         SetRect(playerRects[0, 4], 260, 0, 308, 37);        {flapping}
  71.         SetRect(playerRects[0, 5], 309, 0, 357, 37);        {flapping}
  72.         SetRect(playerRects[1, 0], 407, 38, 455, 86);        {Rects for player facing left    }
  73.         SetRect(playerRects[1, 1], 358, 38, 406, 86);        {walking}
  74.         SetRect(playerRects[1, 2], 407, 38, 455, 86);        {walking}
  75.         SetRect(playerRects[1, 3], 358, 38, 406, 86);        {walking}
  76.         SetRect(playerRects[1, 4], 407, 0, 455, 37);        {flapping}
  77.         SetRect(playerRects[1, 5], 358, 0, 406, 37);        {flapping}
  78.  
  79.         SetRect(boneRects[0, 6], 260, 87, 308, 124);        {Falling skeleton left    }
  80.         SetRect(boneRects[1, 6], 309, 87, 357, 124);        {Falling skeleton right    }
  81.         SetRect(boneRects[0, 7], 456, 25, 501, 47);            {Pile of bones - left        }
  82.         SetRect(boneRects[1, 7], 456, 25, 501, 47);            {Same bones for right    }
  83.  
  84.         SetRect(enemyRects[0, 0, 0], 49, 123, 97, 171);    {enemy 1 walking right}
  85.         SetRect(enemyRects[0, 1, 0], 0, 123, 48, 171);    {enemy 1 walking right}
  86.         SetRect(enemyRects[0, 2, 0], 49, 123, 97, 171);    {enemy 1 walking right}
  87.         SetRect(enemyRects[0, 3, 0], 0, 123, 48, 171);    {enemy 1 walking right}
  88.         SetRect(enemyRects[0, 4, 0], 65, 0, 129, 40);        {enemy 1 flapping left}
  89.         SetRect(enemyRects[0, 5, 0], 0, 0, 64, 40);            {enemy 1 flapping left}
  90.         SetRect(enemyRects[1, 0, 0], 49, 172, 97, 220);    {enemy 2 walking right}
  91.         SetRect(enemyRects[1, 1, 0], 0, 172, 48, 220);    {enemy 2 walking right}
  92.         SetRect(enemyRects[1, 2, 0], 49, 172, 97, 220);    {enemy 2 walking right}
  93.         SetRect(enemyRects[1, 3, 0], 0, 172, 48, 220);    {enemy 2 walking right}
  94.         SetRect(enemyRects[1, 4, 0], 65, 41, 129, 81);    {enemy 2 flapping left}
  95.         SetRect(enemyRects[1, 5, 0], 0, 41, 64, 81);        {enemy 2 flapping left}
  96.         SetRect(enemyRects[2, 0, 0], 49, 221, 97, 269);    {enemy 3 walking right}
  97.         SetRect(enemyRects[2, 1, 0], 0, 221, 48, 269);    {enemy 3 walking right}
  98.         SetRect(enemyRects[2, 2, 0], 49, 221, 97, 269);    {enemy 3 walking right}
  99.         SetRect(enemyRects[2, 3, 0], 0, 221, 48, 269);    {enemy 3 walking right}
  100.         SetRect(enemyRects[2, 4, 0], 65, 82, 129, 122);    {enemy 3 flapping left}
  101.         SetRect(enemyRects[2, 5, 0], 0, 82, 64, 122);        {enemy 3 flapping left}
  102.  
  103.         SetRect(enemyRects[0, 0, 1], 98, 123, 146, 171);    {enemy 1 walking left}
  104.         SetRect(enemyRects[0, 1, 1], 147, 123, 195, 171);    {enemy 1 walking left}
  105.         SetRect(enemyRects[0, 2, 1], 98, 123, 146, 171);    {enemy 1 walking left}
  106.         SetRect(enemyRects[0, 3, 1], 147, 123, 195, 171);    {enemy 1 walking left}
  107.         SetRect(enemyRects[0, 4, 1], 130, 0, 194, 40);        {enemy 1 flapping right}
  108.         SetRect(enemyRects[0, 5, 1], 195, 0, 259, 40);        {enemy 1 flapping right}
  109.         SetRect(enemyRects[1, 0, 1], 98, 172, 146, 220);    {enemy 2 walking left}
  110.         SetRect(enemyRects[1, 1, 1], 147, 172, 195, 220);    {enemy 2 walking left}
  111.         SetRect(enemyRects[1, 2, 1], 98, 172, 146, 220);    {enemy 2 walking left}
  112.         SetRect(enemyRects[1, 3, 1], 147, 172, 195, 220);    {enemy 2 walking left}
  113.         SetRect(enemyRects[1, 4, 1], 130, 41, 194, 81);        {enemy 2 flapping right}
  114.         SetRect(enemyRects[1, 5, 1], 195, 41, 259, 81);        {enemy 2 flapping right}
  115.         SetRect(enemyRects[2, 0, 1], 98, 221, 146, 269);    {enemy 3 walking left}
  116.         SetRect(enemyRects[2, 1, 1], 147, 221, 195, 269);    {enemy 3 walking left}
  117.         SetRect(enemyRects[2, 2, 1], 98, 221, 146, 269);    {enemy 3 walking left}
  118.         SetRect(enemyRects[2, 3, 1], 147, 221, 195, 269);    {enemy 3 walking left}
  119.         SetRect(enemyRects[2, 4, 1], 130, 82, 194, 122);    {enemy 3 flapping right}
  120.         SetRect(enemyRects[2, 5, 1], 195, 82, 259, 122);    {enemy 3 flapping right}
  121.  
  122.         enemyLift[0] := -1;
  123.         enemyLift[1] := -2;
  124.         enemyLift[2] := -4;
  125.  
  126.         SetRect(handRects[0], 358, 87, 422, 144);
  127.         SetRect(handRects[1], 424, 87, 489, 144);
  128.  
  129.         SetRect(ankRects[0], 245, 180, 261, 203);
  130.         SetRect(ankRects[1], 262, 180, 278, 203);
  131.         SetRect(ankRects[2], 279, 180, 295, 203);
  132.         SetRect(ankRects[3], 296, 180, 312, 203);
  133.         SetRect(ankRects[4], 313, 180, 329, 203);
  134.         SetRect(ankRects[5], 330, 180, 346, 203);
  135.         SetRect(ankRects[6], 347, 180, 363, 203);
  136.         SetRect(ankRects[7], 364, 180, 380, 203);
  137.         SetRect(ankRects[8], 381, 180, 397, 203);
  138.         SetRect(ankRects[9], 364, 180, 380, 203);
  139.         SetRect(ankRects[10], 347, 180, 363, 203);
  140.         SetRect(ankRects[11], 330, 180, 346, 203);
  141.         SetRect(ankRects[12], 313, 180, 329, 203);
  142.         SetRect(ankRects[13], 296, 180, 312, 203);
  143.         SetRect(ankRects[14], 279, 180, 295, 203);
  144.         SetRect(ankRects[15], 262, 180, 278, 203);
  145.  
  146.         for i := 0 to 1 do
  147.             for i2 := 0 to 5 do
  148.                 SetRect(absoluteRects[i, i2], 0, 0, playerRects[i, i2].right - playerRects[i, i2].left, playerRects[i, i2].bottom - playerRects[i, i2].top);
  149.  
  150.         running[-16, 0, 0] := -14;    {new hori velocity}
  151.         running[-16, 0, 1] := 1;        {bird leg mode}
  152.         running[-15, 0, 0] := -13;
  153.         running[-15, 0, 1] := 1;
  154.         running[-14, 0, 0] := -12;
  155.         running[-14, 0, 1] := 1;
  156.         running[-13, 0, 0] := -11;
  157.         running[-13, 0, 1] := 1;
  158.         running[-12, 0, 0] := -10;
  159.         running[-12, 0, 1] := 1;
  160.         running[-11, 0, 0] := -9;
  161.         running[-11, 0, 1] := 1;
  162.         running[-10, 0, 0] := -8;
  163.         running[-10, 0, 1] := 1;
  164.         running[-9, 0, 0] := -7;
  165.         running[-9, 0, 1] := 1;
  166.         running[-8, 0, 0] := -6;
  167.         running[-8, 0, 1] := 1;
  168.         running[-7, 0, 0] := -5;
  169.         running[-7, 0, 1] := 1;
  170.         running[-6, 0, 0] := -4;
  171.         running[-6, 0, 1] := 1;
  172.         running[-5, 0, 0] := -3;
  173.         running[-5, 0, 1] := 1;
  174.         running[-4, 0, 0] := -2;
  175.         running[-4, 0, 1] := 1;
  176.         running[-3, 0, 0] := -1;
  177.         running[-3, 0, 1] := 1;
  178.         running[-2, 0, 0] := 0;
  179.         running[-2, 0, 1] := 1;
  180.         running[-1, 0, 0] := 1;
  181.         running[-1, 0, 1] := 1;
  182.         running[0, 0, 0] := 4;
  183.         running[0, 0, 1] := 0;
  184.         running[1, 0, 0] := 4;
  185.         running[1, 0, 1] := 0;
  186.         running[2, 0, 0] := 4;
  187.         running[2, 0, 1] := 0;
  188.         running[3, 0, 0] := 12;
  189.         running[3, 0, 1] := 3;
  190.         running[4, 0, 0] := 11;
  191.         running[4, 0, 1] := 1;
  192.         running[5, 0, 0] := 4;
  193.         running[5, 0, 1] := 0;
  194.         running[6, 0, 0] := 4;
  195.         running[6, 0, 1] := 0;
  196.         running[7, 0, 0] := 4;
  197.         running[7, 0, 1] := 0;
  198.         running[8, 0, 0] := 12;
  199.         running[8, 0, 1] := 3;
  200.         running[9, 0, 0] := 12;
  201.         running[9, 0, 1] := 3;
  202.         running[10, 0, 0] := 12;
  203.         running[10, 0, 1] := 3;
  204.         running[11, 0, 0] := 3;
  205.         running[11, 0, 1] := 2;
  206.         running[12, 0, 0] := 4;
  207.         running[12, 0, 1] := 0;
  208.         running[13, 0, 0] := 11;
  209.         running[13, 0, 1] := 1;
  210.         running[14, 0, 0] := 12;
  211.         running[14, 0, 1] := 1;
  212.         running[15, 0, 0] := 13;
  213.         running[15, 0, 1] := 1;
  214.         running[16, 0, 0] := 14;
  215.         running[16, 0, 1] := 1;
  216.  
  217.         for i := -16 to 16 do
  218.             begin
  219.                 running[i, 1, 0] := -running[-i, 0, 0];
  220.                 running[i, 1, 1] := running[-i, 0, 1];
  221.             end;
  222.  
  223.         for i := 2 to 16 do
  224.             begin
  225.                 idleLanded[i] := i - 2;
  226.                 idleLanded[-i] := -i + 2;
  227.             end;
  228.         idleLanded[-1] := 0;
  229.         idleLanded[0] := 0;
  230.         idleLanded[1] := 0;
  231.  
  232.         for i := -16 to -1 do
  233.             begin
  234.                 gliding[i, 0] := i + 3;
  235.                 gliding[-i, 1] := -i - 3;
  236.             end;
  237.  
  238.         for i := 0 to 14 do
  239.             begin
  240.                 gliding[i, 0] := i + 2;
  241.                 gliding[-i, 1] := -i - 2;
  242.             end;
  243.  
  244.         gliding[16, 0] := 16;
  245.         gliding[-16, 1] := -16;
  246.         gliding[15, 0] := 16;
  247.         gliding[-15, 1] := -16;
  248.  
  249.         for i := -70 to 16 do
  250.             begin
  251.                 impacted[i] := (-2 * i) div 3;
  252.             end;
  253.         SetRect(tombRects[-5], -61, 424, 206, 440);    {acid cover left}
  254.         SetRect(tombRects[-4], 433, 424, 700, 440);    {acid cover right}
  255.         SetRect(tombRects[-3], 232, 180, 407, 197);    {top floor center}
  256.         SetRect(tombRects[-2], 206, 424, 433, 460);    {bottom floor center}
  257.         SetRect(tombRects[-1], -61, 424, 700, 440);    {whole floor bottom}
  258.         SetRect(tombRects[0], 206, 424, 433, 460);    {bottom floor center}
  259.         SetRect(tombRects[1], -117, 283, 150, 300);    {bottom floor left}
  260.         SetRect(tombRects[2], 490, 283, 757, 300);    {bottom floor right}
  261.         SetRect(tombRects[3], -107, 104, 160, 121);    {top floor left}
  262.         SetRect(tombRects[4], 480, 104, 747, 121);    {top floor right}
  263.         SetRect(tombRects[5], 232, 180, 407, 197);    {top floor center}
  264.         SetRect(tombRects[6], -61, 424, 206, 440);    {acid cover left}
  265.  
  266.         SetRect(eyeRects[0], 196, 219, 244, 250);
  267.         SetRect(eyeRects[1], 196, 187, 244, 218);
  268.         SetRect(eyeRects[2], 196, 155, 244, 186);
  269.         SetRect(eyeRects[3], 196, 123, 244, 154);
  270.         SetRect(eyeRects[4], 196, 123, 244, 154);
  271.  
  272.         with theEye do
  273.             begin
  274.                 dest := eyeRects[4];
  275.                 CenterZeroRect(dest);
  276.                 OffsetRect(dest, 320, upperEyeHeight);
  277.                 oldDest := dest;
  278.             end;
  279.  
  280.         SetRect(eggRects, 456, 0, 480, 24);
  281.         SetRect(flameRect[0], 80, 307, 112, 342);
  282.         SetRect(flameRect[1], 528, 307, 560, 342);
  283.         SetRect(shortStoneSrc, 337, 236, 512, 253);
  284.         SetRect(longStoneSrc, 245, 253, 512, 270);
  285.         SetRect(playRect, 15, 37, 625, 440);
  286.         SetRect(gameoverRects, 245, 145, 457, 179);
  287.  
  288.         doneFlag := FALSE;
  289.  
  290.         NewLightning;
  291.         ReadInScores;
  292.         CloseLogoWindo;
  293.         RedoTheBackground;
  294.         DoTheSound('music.snd', highPriority);
  295.         ReDrawHiScores;
  296.         FlushEvents(everyEvent, 0);
  297.         repeat
  298.         until (soundPriority = noSound);
  299.         InitCursor;
  300.         CopyMask(BitMapPtr(objectCPtr^.portPixMap^)^, offMaskMap, mainWndo^.portBits, eyeRects[4], eyeRects[4], theEye.dest);
  301.         DoTheSound('lightning.snd', highPriority);
  302.         SetPort(GrafPtr(mainWndo));
  303.         for i := 1 to 3 do
  304.             StrikeLightning(upperEye);
  305.         CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, theEye.dest, theEye.dest, srcCopy, playRgn);
  306.         FlushEvents(everyEvent, 0);
  307.     end;
  308.  
  309. {=================================}
  310.  
  311. end.